package cn.springcloud.book;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.sleuth.instrument.async.TraceableExecutorService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by wudl on 2018/12/1.
 */
@Configuration
public class ConsumerConfiguration {
    @Autowired
    BeanFactory beanFactory;

    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public ExecutorService executorService() {
            ExecutorService executorService = Executors.newFixedThreadPool(2);
            return new TraceableExecutorService(this.beanFactory,executorService);
    }
}
